#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int numRollsToTarget(int n, int k, int target) {
    vector<vector<int>> dp(n + 1, vector<int>(target + 1));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= target; j++)
            for (int x = 1; x <= k; x++)
                if (j - x >= 0)
                    dp[i][j] = (dp[i][j] + dp[i - 1][j - x]) % 1000000007;
    return dp[n][target];
}